﻿Type=Activity
Version=3.15
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.
	Dim V_XM As String
	Dim V_CH As String
	Dim V_BHID As Int
	Dim V_BLID As Int
	Dim FBLID As Int
	Dim FBLData As String
	Dim FBTList As List
End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.

	Dim wbvHLNR As WebView
	
	Dim HttpJobTool As HttpJob
End Sub

Sub Activity_Create(FirstTime As Boolean)
	Activity.LoadLayout("FormBHHLNRInfo")
	
	Activity.Title = "病人护理记录内容信息-"  & V_CH & " " &V_XM 
	
	InitLayOut

End Sub

Sub Activity_Resume
	If FBLID<>V_BLID Then
		RefreshData
	Else
		wbvHLNR.LoadHtml(FBLData)
		SetTitleList(FBTList)
	End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub InitLayOut


End Sub

Sub RefreshData
	Dim sURL,sSession,sBHID,sBLID,sText As String
	
	sSession = PublicVar.GV_DesTool.Base64encrypt(PublicVar.GV_UserSession)
	
	sBHID = PublicVar.GV_DesTool.Base64encrypt(V_BHID)
	sBLID = PublicVar.GV_DesTool.Base64encrypt(V_BLID)
	
	sText = "Session=" & sSession & "&BHID=" & sBHID & "&BLID=" & sBLID

	sURL = PublicVar.GetServerUrl&"/getbhhlnrinfo"
	HttpJobTool.Initialize("Job1",Me)
	HttpJobTool.PostString(sURL,sText)
	ProgressDialogShow("正在获取数据，请稍候...")	

End Sub

Sub JobDone (Job As HttpJob)
   Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
   If Job.Success = True Then
      If Job.JobName = "Job1" Then
				HttpJobSuccess(Job)
      End If
   Else
		HttpJobError(Job)
   End If
   Job.Release
End Sub

Sub HttpJobSuccess(Job As HttpJob) 
	Dim sResult,sCode,sData,sHtml,sAdd As String
	Dim iPos0,iPos1 As Int
	Dim mapResult As Map
	
	ProgressDialogHide
	sResult = Job.GetString.Trim
	
	PublicVar.GV_JSonTool.Initialize(sResult)
	mapResult = PublicVar.GV_JSonTool.NextObject
	
	sCode = mapResult.Get("Code")
	If sCode<>"0" Then
		sResult = mapResult.Get("Message")
		ToastMessageShow("获取数据失败"&CRLF &sResult, True)	
		
		PublicVar.CheckSession(sCode)
		
		Return
	End If
	
	sData = mapResult.Get("Data")
	If sData ="" Then
		ToastMessageShow("获取数据失败"&CRLF &"返回的数据为空", True)	
		Return	
	
	End If
	
	sData = PublicVar.GV_DesTool.Base64decrypt(sData)
	sHtml = sData
	iPos0 = sData.IndexOf(PublicVar.GV_HTML_ADD_DATA_BEGIN)
	If iPos0 > -1 Then
		iPos1 = sData.IndexOf(PublicVar.GV_HTML_ADD_DATA_END)
		sHtml = sData.SubString2(0,iPos0) 	
		sAdd = sData.SubString2(iPos0+PublicVar.GV_HTML_ADD_DATA_BEGIN.Length,iPos1)
	End If
	
	wbvHLNR.LoadHtml(sHtml)
	FBLData = sHtml
	FBLID = V_BLID
	
	If sAdd.Length >0 Then
		PublicVar.GV_JSonTool.Initialize(sAdd)
		FBTList = PublicVar.GV_JSonTool.NextArray		
		SetTitleList(FBTList)
	End If
	
End Sub

Sub HttpJobError(Job As HttpJob) 
	Dim sMsg As String
	ProgressDialogHide
	
	Log("Error: " & Job.ErrorMessage)
	sMsg = "获取护理记录内容失败."& CRLF & Job.ErrorMessage 
  ToastMessageShow(sMsg, True)
End Sub

Sub SetTitleList(AList As List)
'	Dim mapResult As Map 
'	For i = 0 To AList.Size - 1 
'		mapResult = AList.Get(i)
'		
'		Activity.AddMenuItem(mapResult.Get("title"),"MenuItemAdv")
'	Next
	
End Sub
